'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  //token白名单
  router.post('/api/create/user', controller.user.createUser);// 注册用户
  router.post('/api/login', controller.user.login);// 登陆
  router.post('/api/admin/login', controller.admin.login);// 后台登陆
  router.post('/api/admin/register', controller.admin.createUser);// 后台注册
  // 手机端信息接口
  router.post('/create/needDrug', middleware.jwtVerify(app.config.jwt), controller.needHelp.createHelp); // 添加求助信息
  router.put('/edit/needDrug', middleware.jwtVerify(app.config.jwt), controller.needHelp.editHelp); // 更新求助信息
  router.post('/create/provideDrug', middleware.jwtVerify(app.config.jwt), controller.proHelp.createNeedHelp); // 添加帮助信息
  router.put('/edit/provideDrug', middleware.jwtVerify(app.config.jwt), controller.proHelp.editProHelp); // 更新帮助信息
  router.get('/drug/showHelp', middleware.jwtVerify(app.config.jwt), controller.needHelp.showHelp); // 展示求助
  router.get('/drug/showProHelp', middleware.jwtVerify(app.config.jwt), controller.proHelp.showProHelp); // 展示帮助
  // 管理员相关
  router.get('/manage/drug/showHelp', middleware.jwtVerify(app.config.jwt), controller.admin.manageShowHelp); // 管理员展示求助
  router.get('/manage/drug/showProHelp', middleware.jwtVerify(app.config.jwt), controller.admin.manageShowProHelp); // 管理员展示帮助
  router.put('/manage/edit/needDrug', middleware.jwtVerify(app.config.jwt), controller.admin.examineHelp); // 审核求助信息
  router.put('/manage/edit/provideDrug', middleware.jwtVerify(app.config.jwt), controller.admin.examineProHelp); // 审核帮助信息
  router.delete('/manage/delete/needDrug', middleware.jwtVerify(app.config.jwt), controller.admin.delHelp); // 删除求助
  router.delete('/manage/delete/provideDrug', middleware.jwtVerify(app.config.jwt), controller.admin.delProHelp); // 删除帮助
  // 管理员---管理用户相关
  router.get('/manage/drug/showUser', middleware.jwtVerify(app.config.jwt), controller.admin.showUser); // 管理员展示用户数据
  router.get('/manage/drug/showAdminUser', middleware.jwtVerify(app.config.jwt), controller.admin.showAdminUser); // 管理员展示后台用户数据
  router.put('/manage/drug/editUser', middleware.jwtVerify(app.config.jwt), controller.admin.editUser); // 管理员更新用户数据
  router.put('/manage/drug/editAdminUser', middleware.jwtVerify(app.config.jwt), controller.admin.editAdminUser); // 管理员更新后台用户数据
  router.delete('/manage/drug/deleteUser', middleware.jwtVerify(app.config.jwt), controller.admin.deleteUser); // 管理员删除用户数据
  router.delete('/manage/drug/deleteAdminUser', middleware.jwtVerify(app.config.jwt), controller.admin.deleteAdminUser); // 管理员删除后台用户数据
  //后台界面 -- api管理相关
  router.post('/manage/create/api', middleware.jwtVerify(app.config.jwt), controller.api.createApi); // 添加api
  router.get('/manage/show/api', middleware.jwtVerify(app.config.jwt), controller.api.showApi); // 展示api
  router.get('/manage/show/allApi', middleware.jwtVerify(app.config.jwt), controller.api.showAllApi); // 展示所有api
  router.put('/manage/edit/api', middleware.jwtVerify(app.config.jwt), controller.api.editApi); // 更新api
  router.delete('/manage/delete/api', middleware.jwtVerify(app.config.jwt), controller.api.deleteApi); // 删除api
  //后台界面 -- 角色相关
  router.post('/manage/create/role', middleware.jwtVerify(app.config.jwt), controller.role.createRole); // 添加角色
  router.get('/manage/show/role', middleware.jwtVerify(app.config.jwt), controller.role.showRole); // 展示role
  router.put('/manage/edit/role', middleware.jwtVerify(app.config.jwt), controller.role.editRole); // 更新role
  router.delete('/manage/delete/role', middleware.jwtVerify(app.config.jwt), controller.role.deleteRole); // 删除role

  // 后台界面 -- dashboard
  router.get('/manage/home/showInfo', middleware.jwtVerify(app.config.jwt), controller.home.showInfo); //dashboard展示信息
  router.get('/manage/home/showCoronavirus', middleware.jwtVerify(app.config.jwt), controller.home.showCoronavirus); //dashboard展示疫情
};
